Check if a String is a Pangram

Theory:

A pangram is a string that contains every letter of the alphabet at least once. This includes both uppercase and lowercase letters.

Python Code:

import string

def is_pangram(sentence):
    alphabet = set(string.ascii_lowercase)
    return set(sentence.lower()) >= alphabet

# Taking input for the sentence and checking if it is a pangram
def check_and_display_pangram():
    sentence = input("Enter a sentence: ")
    if is_pangram(sentence):
        print("The sentence is a pangram.")
    else:
        print("The sentence is not a pangram.")

check_and_display_pangram()

Example Output 1:

Enter a sentence: The quick brown fox jumps over the lazy dog

The sentence is a pangram.

Example Output 2:

Enter a sentence: This is not a pangram

The sentence is not a pangram.

Code Explanation:

The function is_pangram(sentence) checks whether a given sentence is a pangram or not by comparing the set of lowercase letters in the sentence with the set of all lowercase letters in the alphabet.

The function check_and_display_pangram() takes input for the sentence, checks if it is a pangram using the aforementioned function, and displays the result.